View Javadoc
1 /* 2 * Angkor Web Framework 3 * 4 * Distributable under LGPL license. 5 * See terms of license at gnu.org. 6 */ 7 8 package com.tirsen.angkor.event; 9 10 import com.tirsen.angkor.Debug; 11 import com.tirsen.angkor.Multicaster; 12 import com.tirsen.angkor.RenderContext; 13 import org.apache.log4j.Category; 14 15 import java.io.Serializable; 16 17 /*** 18 * Utility class for sending change events. 19 * 20 * <!-- $Id: ChangeSourceHelper.java,v 1.3 2002/10/09 21:37:37 tirsen Exp $ --> 21 * 22 * @author $Author: tirsen $ 23 * @version $Revision: 1.3 $ 24 */ 25 public class ChangeSourceHelper implements ChangeSource, Serializable 26 { 27 private static final Category logger = Category.getInstance(Debug.LOGGER_NAME); 28 private Object source; 29 private ChangeListener listeners; 30 31 public ChangeSourceHelper(Object source) 32 { 33 this.source = source; 34 } 35 36 public void addChangeListener(ChangeListener listener) 37 { 38 if (listeners == null) listeners = (ChangeListener) Multicaster.create(ChangeListener.class, true); 39 Multicaster.add(listeners, listener); 40 } 41 42 public void removeChangeListener(ChangeListener listener) 43 { 44 listeners = (ChangeListener) Multicaster.remove(listeners, listener); 45 } 46 47 public void signalChangeEvent(RenderContext context) 48 { 49 if (!Multicaster.isEmpty(listeners)) 50 { 51 ChangeEvent evt = new ChangeEvent(source); 52 context.getEventQueue().postEvent(ChangeListener.class, listeners, evt, "stateChanged"); 53 } 54 } 55 56 public void signalChangeEvent() 57 { 58 if (!Multicaster.isEmpty(listeners)) 59 { 60 ChangeEvent evt = new ChangeEvent(source); 61 RenderContext.getRenderContext().getEventQueue().postEvent(ChangeListener.class, listeners, evt, "stateChanged"); 62 } 63 } 64 }

This page was automatically generated by Maven